package com.biye.api.controller.admin;

import com.alibaba.fastjson.JSONObject;
import com.biye.api.service.AuthorityService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author Maple.Chen
 * @Description Authority
 * @Date 13:35 2021/4/9
 **/
@Controller
@RequestMapping(value = "/admin")
public class AuthorityController {

    @Resource
    private AuthorityService authorityService;

    // 查询所有权限list(role+group)
    @RequestMapping(value = "auQuery", method = RequestMethod.GET)
    @ResponseBody
    public JSONObject queryAllRoleOrGroupAuthorityList(){
        return authorityService.queryAllRoleOrGroupAuthorityList();
    }

    // 根据职工id获取该职工的权限list(role+group)
    @RequestMapping(value = "auOne", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject queryAllRoleOrGroupAuthorityListByStaffId(@RequestBody Map<String, Object> request){
        return authorityService.queryAllRoleOrGroupAuthorityListByStaffId(request);
    }

    // 更新改用户的权限list(role+group)
    @RequestMapping(value = "auUpd", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateStaffAuthorityList(@RequestBody Map<String, Object> requestMap){
        return authorityService.updateStaffAuthorityList(requestMap);
    }

}
